<!DOCTYPE html>
<html lang="en-US">
  <head>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
    <link href="/assets/focusManagement.css" rel="stylesheet" type="text/css" />
    <script crossorigin="anonymous" src="/test-harness.js"></script>
    <script crossorigin="anonymous" src="/test-page-object.js"></script>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
  </head>
  <body>
    <main id="webchat"></main>
    <script>
      run(async function () {
        const store = testHelpers.createStore();
        const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
        const baseProps = { directLine, store, styleOptions: { subtle: '#666' } };
        const webChatElement = document.getElementById('webchat');

        WebChat.renderWebChat(baseProps, webChatElement);

        await pageConditions.uiConnected();

        await pageObjects.sendMessageViaSendBox('receiptcard', { waitForSend: true });
        await pageConditions.minNumActivitiesShown(2);
        await pageConditions.allImagesLoaded();
        await pageConditions.scrollToBottomCompleted();

        document.querySelector('img[tabindex="0"]').focus();

        await host.sendShiftTab();

        const focusingOnRoot =
          document.activeElement === document.querySelector('.webchat__adaptive-card-renderer').firstChild;

        expect(focusingOnRoot).toBe(true);

        // The whole card should become yellow as the focus moved on it and it is clickable.
        await host.snapshot('local');
      });
    </script>
  </body>
</html>
